package com.example;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;

public class StoreData {
    public static void main(String[] args){

        Configuration configuration = new Configuration();
        configuration.configure("hibernate.cfg.xml");

        SessionFactory sessionFactory = configuration.buildSessionFactory();

        Session session = sessionFactory.openSession();

        Transaction transaction = session.beginTransaction();

        Student student = new Student();
        student.setId(1);
        student.setName("John");
        student.setAddress("NewYork");
        student.setPassword("123456");
        student.setSex("man");

//        session.persist(student);
        session.save(student);
        transaction.commit();
        session.close();

        System.out.println("Successful saved.");
    }
}
